/* GUI CONVERTED from rescrapi.p (converter v1.76) Wed May 22 11:22:48 2002 */
/* rescrapi.p - REPETITIVE Scrap Transaction subprogram -get 2nd frame data   */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.11 $                                                          */
/*V8:ConvertMode=Maintenance                                                  */
/* REVISION: 7.3      LAST MODIFIED: 10/31/94   BY: WUG *GN77*                */
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane          */
/* REVISION: 8.6E     LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan         */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan         */
/* REVISION: 9.1      LAST MODIFIED: 10/25/99   BY: *N002* Bill Gates         */
/* REVISION: 9.1      LAST MODIFIED: 11/17/99   BY: *N04H* Vivek Gogte        */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane   */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KP* myb                */
/* REVISION: 9.1      LAST MODIFIED: 09/11/00   BY: *N0RS* Mudit Mehta        */
/* Old ECO marker removed, but no ECO header exists *F0PN*                    */
/* $Revision: 1.11 $    BY: Jean Miller          DATE: 04/26/02  ECO: *P05V*  */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

{mfdeclre.i}
{gplabel.i} /* EXTERNAL LABEL INCLUDE */

define input parameter cumwo_lot as character.
define input parameter cumwo_op as integer.
define output parameter undo_stat like mfc_logical no-undo.

define shared variable rsn_codes               as character     extent 10.
define shared variable quantities              like wr_qty_comp extent 10.
define shared variable inque_scrap_rsn_codes   as character     extent 10.
define shared variable inque_scrap_quantities  like wr_qty_comp extent 10.
define shared variable outque_scrap_rsn_codes  as character     extent 10.
define shared variable outque_scrap_quantities like wr_qty_comp extent 10.
define shared variable rejque_scrap_rsn_codes  as character     extent 10.
define shared variable rejque_scrap_quantities like wr_qty_comp extent 10.

define shared variable h_wiplottrace_procs as handle no-undo.
define shared variable h_wiplottrace_funcs as handle no-undo.

{wlfnc.i} /*FUNCTION FORWARD DECLARATIONS*/
{wlcon.i}

for first wo_mstr where wo_lot = cumwo_lot
no-lock: end.

{retrform.i}

define variable i as integer.
define variable j as integer.
define variable date_change as integer.
define variable elapse as decimal format ">>>>>>>>.999".
define variable undostat like mfc_logical no-undo.
define variable first_op like mfc_logical.
define variable new_conv like conv.

find last wr_route where wr_lot = cumwo_lot and
                         wr_op < cumwo_op
no-lock no-error.

first_op = not available wr_route.

undo_stat = yes.

do with frame scrap1 on error undo, retry:
/*GUI*/ if global-beam-me-up then undo, leave.


   {regetwcm.i &framename=scrap1}

   do with frame scrap1 on error undo, retry:
/*GUI*/ if global-beam-me-up then undo, leave.


      set
         dept
         um
         conv
         qty_inque          when (not first_op)
         inque_rsn_code     when (not first_op and
                                  not (is_wiplottrace_enabled() and
                                       is_operation_queue_lot_controlled
                                       (cumwo_lot, cumwo_op, INPUT_QUEUE)))
         inque_multi_entry  when (not first_op and
                                  not (is_wiplottrace_enabled() and
                                       is_operation_queue_lot_controlled
                                       (cumwo_lot, cumwo_op, INPUT_QUEUE)))
         qty_outque
         outque_rsn_code    when (not (is_wiplottrace_enabled() and
                                       is_operation_queue_lot_controlled
                                       (cumwo_lot, cumwo_op, OUTPUT_QUEUE)))

         outque_multi_entry when (not (is_wiplottrace_enabled() and
                                       is_operation_queue_lot_controlled
                                       (cumwo_lot, cumwo_op, OUTPUT_QUEUE)))
         qty_rejque
         rejque_rsn_code    when (not (is_wiplottrace_enabled() and
                                       is_operation_queue_lot_controlled
                                       (cumwo_lot, cumwo_op, REJECT_QUEUE)))
         rejque_multi_entry when (not (is_wiplottrace_enabled() and
                                       is_operation_queue_lot_controlled
                                       (cumwo_lot, cumwo_op, REJECT_QUEUE)))
      editing:

         if frame-field = "dept" then do:
            {mfnp05.i dpt_mstr dpt_dept yes dpt_dept
               "input frame scrap1 dept"}
            if recno <> ? then display dpt_dept @ dept dpt_desc.
         end.

         else
         if frame-field = "inque_rsn_code" then do:
            {mfnp05.i rsn_ref rsn_type "rsn_type = ""scrap"""
               rsn_code
               "input frame scrap1 inque_rsn_code"}
            if recno <> ? then
               display rsn_code @ inque_rsn_code.
         end.

         else
         if frame-field = "outque_rsn_code" then do:
            {mfnp05.i rsn_ref rsn_type "rsn_type = ""scrap"""
               rsn_code
               "input frame scrap1 outque_rsn_code"}
            if recno <> ? then
               display rsn_code @ outque_rsn_code.
         end.

         else
         if frame-field = "rejque_rsn_code" then do:
            {mfnp05.i rsn_ref rsn_type "rsn_type = ""scrap"""
               rsn_code
               "input frame scrap1 rejque_rsn_code"}
            if recno <> ? then
               display rsn_code @ rejque_rsn_code.
         end.

         else do:
            ststatus = stline[3].
            status input ststatus.
            readkey.
            apply lastkey.
         end.

      end. /* set, editing */

      find dpt_mstr where dpt_dept = dept no-lock no-error.

      if not available dpt_mstr then do:
         next-prompt dept.
         /* Department not found */
         {pxmsg.i &MSGNUM=532 &ERRORLEVEL=3}
         undo, retry.
      end.

      display dpt_desc.

      find pt_mstr where pt_part = part no-lock.

      if um <> pt_um then do:
         {gprun.i ""gpumcnv.p""
            "(input um, input pt_um, input part, output new_conv)"}
/*GUI*/ if global-beam-me-up then undo, leave.


         if new_conv = ? then do:
            /* UOM Conversion not available */
            {pxmsg.i &MSGNUM=33 &ERRORLEVEL=2}
         end.

         else do:
            if not frame scrap1 conv entered then do:
               conv = new_conv.
               display conv.
            end.
         end.

      end.

      else
         display
            conv
         with frame scrap1.

      if not first_op then do:
         find rsn_ref where rsn_code = inque_rsn_code
                        and rsn_type = "scrap"
         no-lock no-error.
         if not available rsn_ref and inque_rsn_code > "" then do:
            /* Reason code does not exist */
            {pxmsg.i &MSGNUM=534 &ERRORLEVEL=2 &MSGARG1=inque_rsn_code}
         end.
      end.

      find rsn_ref where rsn_code = outque_rsn_code
                     and rsn_type = "scrap"
      no-lock no-error.

      if not available rsn_ref and outque_rsn_code > "" then do:
         /* Reason code does not exist */
         {pxmsg.i &MSGNUM=534 &ERRORLEVEL=2 &MSGARG1=outque_rsn_code}
      end.

      find rsn_ref where rsn_code = rejque_rsn_code
                      and rsn_type = "scrap"
      no-lock no-error.

      if not available rsn_ref and rejque_rsn_code > "" then do:
         /* Reason code does not exist */
         {pxmsg.i &MSGNUM=534 &ERRORLEVEL=2 &MSGARG1=rejque_rsn_code}
      end.

      if inque_multi_entry then do:

         do i = 1 to 10:
            rsn_codes[i] = inque_scrap_rsn_codes[i].
            quantities[i] = inque_scrap_quantities[i].
         end.

         {gprun.i ""resrqrin.p""
            "(input ""scrap"",
              input getTermLabel(""INPUT_QUEUE_SCRAP"",35),
              output undostat)"}
/*GUI*/ if global-beam-me-up then undo, leave.


         if undostat then undo, retry.
         qty_inque = 0.

         do i = 1 to 10:
            inque_scrap_rsn_codes[i] = rsn_codes[i].
            inque_scrap_quantities[i] = quantities[i].
            qty_inque = qty_inque + quantities[i].
         end.

         display qty_inque.

      end.

      if outque_multi_entry then do:

         do i = 1 to 10:
            rsn_codes[i] = outque_scrap_rsn_codes[i].
            quantities[i] = outque_scrap_quantities[i].
         end.

         {gprun.i ""resrqrin.p""
            "(input ""scrap"",
              input getTermLabel(""OUTPUT_QUEUE_SCRAP"",35),
              output undostat)"}
/*GUI*/ if global-beam-me-up then undo, leave.


         if undostat then undo, retry.
         qty_outque = 0.

         do i = 1 to 10:
            outque_scrap_rsn_codes[i] = rsn_codes[i].
            outque_scrap_quantities[i] = quantities[i].
            qty_outque = qty_outque + quantities[i].
         end.

         display qty_outque.

      end.

      if rejque_multi_entry then do:

         do i = 1 to 10:
            rsn_codes[i] = rejque_scrap_rsn_codes[i].
            quantities[i] = rejque_scrap_quantities[i].
         end.

         {gprun.i ""resrqrin.p""
            "(input ""scrap"",
              input getTermLabel(""REJECT_QUEUE_SCRAP"",35),
              output undostat)"}
/*GUI*/ if global-beam-me-up then undo, leave.


         if undostat then undo, retry.
         qty_rejque = 0.

         do i = 1 to 10:
            rejque_scrap_rsn_codes[i] = rsn_codes[i].
            rejque_scrap_quantities[i] = quantities[i].
            qty_rejque = qty_rejque + quantities[i].
         end.

         display qty_rejque.

      end.

   end.
/*GUI*/ if global-beam-me-up then undo, leave.


   undo_stat = no.
end.
/*GUI*/ if global-beam-me-up then undo, leave.

